﻿namespace DCHealthCheck.MvcWeb.Classes.ViewModels {

    #region Usings
    using DCHealthCheck.Common;
    using DCHealthCheck.DomainModel;
    using System;
    using System.Collections.Generic;
    using System.Data.Objects;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Web;
    using System.Web.Mvc;
    #endregion

    public class ServiceInfoViewModel : BaseViewModel {

        #region Members
        public long ProcessId { get; set; }

        /// <summary>
        /// The service executable full path
        /// </summary>
        public string ServiceExecutable { get; set; }

        public List<ServiceInfo> ServiceInfos { get; set; }

        /// <summary>
        /// The service short name
        /// </summary>
        public string ServiceName { get; set; }

        #region Control SelectListItem collections
        public List<SelectListItem> ServiceExecutableSelectListItems { get; private set; }
        public List<SelectListItem> ServiceNameSelectListItems { get; private set; }
        #endregion 
        #endregion

        #region Constructor
        public ServiceInfoViewModel() {
            this.ServiceInfos = new List<ServiceInfo>();
            this.ServiceNameSelectListItems = new List<SelectListItem>();
            this.ServiceExecutableSelectListItems = new List<SelectListItem>();
        } 
        #endregion

        #region Methods
        public override void Initialize(){
            Global.DefaultLog.DebugFormat("[ThreadId: {0}] {1}", Thread.CurrentThread.ManagedThreadId, Extensions.CurrentMethodName());

            base.Initialize();
            this.TakeCount = 15;
            this.DisplayDownloadLink = true;

            if (string.IsNullOrWhiteSpace(this.SortColumn)) {
                this.SortColumn = "Name";
            }

            if (this.ServiceExecutable == null) this.ServiceExecutable = string.Empty;
            if (this.ServiceName == null) this.ServiceName = string.Empty;
        } 
        #endregion
    }
}